#ifndef FRAKOUTVERSIONSTATE_H
#define FRAKOUTVERSIONSTATE_H

#include <functional>

class FrakOutData;
class FrakOutVersion;

/**
 * A class for performing versioned data migration.
 * @author cjr
 */
class FrakOutVersionState
{
public:
    FrakOutVersionState(const FrakOutVersion* const version);
    ~FrakOutVersionState();
    virtual void migrate(FrakOutData& frakOutData) = 0;
    const FrakOutVersion* const version() const;

public:

    /**
     * A functor to match against the version number associated with a version state object.
     * @author cjr
     */
    class MatchVersion : public std::unary_function<const FrakOutVersionState* const, bool>
    {
    public:
        MatchVersion(const FrakOutVersion* const version) : m_version(version)
        {
        }

        bool operator()(const FrakOutVersionState* const versionState) const
        {
            return versionState->version() == m_version;
        }

    private:
        const FrakOutVersion* const m_version;
    };

protected:
    const FrakOutVersion* const m_version;
};

#endif // FRAKOUTVERSIONSTATE_H
